$(function () {
	let downcount;
	$.ajax({
		url: 'http://localhost:70/devc/competition/enroll/1',	//这是后端接口的url
		method: 'post',
		success: function (res) {
			downcount = res;

			var note = $('#note'),
				ts = new Date(2012, 0, 1),
				newYear = true;

			if ((new Date()) > ts) {
				// The new year is here! Count towards something else.
				// Notice the *1000 at the end - time must be in milliseconds
				ts = (new Date()).getTime() + downcount;
				// 10*24*60*60*1000
				newYear = false;
			}

			$('#countdown').countdown({
				timestamp: ts,
				callback: function (days, hours, minutes, seconds) {

					var message = "";

					message += days + " day" + (days == 1 ? '' : 's') + ", ";
					message += hours + " hour" + (hours == 1 ? '' : 's') + ", ";
					message += minutes + " minute" + (minutes == 1 ? '' : 's') + " and ";
					message += seconds + " second" + (seconds == 1 ? '' : 's') + " <br />";

					if (newYear) {
						message += "left until the new year!";
					}
					else {
						message += "left to " + days + " days from now!";
					}

					note.html(message);
				}
			});
		}
	})


});
